// TOWN DIALOGUE SCRIPT
//    Town 0: Llylgamyn

// This is the dialogue for this town.
// You can use states numbered from 1 to 99.

begintalkscript;

variables;

short tt, choice;

// *** Boltac ***
begintalknode 1;
	state = -1;
	personality = 19;
	nextstate = 2;
	condition = 1;
	question = "Boltac";
	text1 = "A large man is working behind the counter.";
	text2 = "He stops what he's working on and says _Welcome to Boltac's._";
	text3 = "_I'm Boltac, what can I do for you?_";
	text5 = "Boltac extends his hand _Welcome back to Boltac's._";
	text6 = "_Let me know what I can do for you._";
	action = INTRO;

begintalknode 2;
	state = 2;
	personality = 19;
	nextstate = -1;
	condition = 1;
	question = "What do you do?";
	text1 = "Boltac lets out a great laugh _Why I buy and sell from adventurers such as yourselves._";
	text2 = "_In addition, I can identify items for you, for a small fee of course._";
	text3 = "_Let me know how I can help._";

begintalknode 3;
	state = 2;
	personality = 19;
	nextstate = -1;
	condition = 1;
	question = "Can you identify my items?";
	text1 = "Boltac starts identifying your items for you.";
	action = ID 40;

begintalknode 4;
	state = 2;
	personality = 19;
	nextstate = -1;
	condition = 1;
	question = "Can I look at you stuff?";
	text1 = "You finish shopping at Boltac's.";
	code =
		begin_shop_mode("Boltac's Trading Post", "Boltac buys and sells from adventurers such as yourself.  The prices are somewhat high.", 1, 4, 4);
	break;

// *** Son of Boltac ***
begintalknode 5;
	state = -1;
	personality = 20;
	nextstate = 6;
	condition = 1;
	question = "Son of Boltac";
	text1 = "A large, young man is working behind the counter.";
	text2 = "He stops and says _Welcome to Boltac's Annex._";
	text3 = "_I am the Son of Boltac, how can I help you?_";
	text5 = "The Son of Boltac extends his hand in greeting.";
	text6 = "_Welcome back.  Let me know if you'd like to view anything._";
	action = INTRO;

begintalknode 6;
	state = 6;
	personality = 20;
	nextstate = -1;
	condition = 1;
	question = "What do you do?";
	text1 = "The Son of Boltac says _I run the annex for my father._";
	text2 = "_There are a large variety of items for sale here._";

begintalknode 7;
	state = 6;
	personality = 20;
	nextstate = -1;
	condition = 1;
	question = "Can I view your stuff?";
	text1 = "You finish shopping at the annex.";
	code =
		begin_shop_mode("Boltac's Annex", "The Son of Boltac buys and sells a variety of items to adventurers.  The prices are somewhat high.", 2, 4, 4);
	break;

// *** Gilgamesh ***
begintalknode 10;
	state = -1;
	personality = 21;
	nextstate = 11;
	condition = 1;
	question = "Gilgamesh";
	text1 = "You see a man wiping glasses behind the bar.";
	text2 = "He smiles at you saying _Welcome to Gilgamesh's Tavern._";
	text3 = "_Names Gilgamesh, what can I get for you?_";
	text5 = "Gilgamesh smiles in your direction.";
	text6 = "_Welcome again adventurers.  Let me know if you need something._";
	action = INTRO;
	code =
		set_flag(0, 11, 0);
	break;

begintalknode 11;
	state = 11;
	personality = 21;
	nextstate = -1;
	condition = 1;
	question = "What do you do?";
	text1 = "Gilgamesh smiles again _Why I run my tavern and serve those who are hungry or thirsty._";
	text2 = "_Just let me know if I can get something for you._";

begintalknode 12;
	state = 11;
	personality = 21;
	nextstate = -1;
	condition = 1;
	question = "Can I see your food menu?";
	text1 = "You finish ordering food from Gilgamesh.";
	code =
		begin_shop_mode("Gilgamesh's Tavern", "Gilgamesh provides a slew of tasty food for the hungry adventurer.  The prices are somewhat high.", 0, 4, -1);
	break;

begintalknode 13;
	state = 11;
	personality = 21;
	nextstate = 14;
	condition = 1;
	question = "I'd like a drink please.";
	text1 = "_A mug of ale is 3 coins, OK?_ asks Gilgamesh.";
	text2 = "He awaits your reply.";
	code =
		set_flag(0, 11, 1);
	break;

begintalknode 14;
	state = 14;
	personality = 21;
	nextstate = -1;
	condition = (get_flag(0, 11) > 0);
	question = "No thanks, not right now.";
	text1 = "Gilgamesh starts polishing a glass.";
	text2 = "_Let me know if you'd like something later_ he says.";
	code =
		set_flag(0, 11, 0);
	break;

begintalknode 15;
	state = 14;
	personality = 21;
	nextstate = -1;
	condition = (get_flag(0, 11) > 0);
	question = "Yes please, I'm thirsty.";
	text1 = "Gilgamesh serves you a big frost mug of ale.";
	text3 = "_You don't have enough coins.  Come back when you do_ Gilgamesh adds.";
	text5 = "Gilgamesh smiles and says _Let me know if you want one later._";
	text7 = "Gilgamesh says _You are too drunk for me to serve.  Go sleep it off first._";
	code =
		set_flag(0, 11, 0);
		clear_strings();
		if (coins_amount() < 3)
			add_string(3);
		else if (run_select_a_pc(1) == 0)
			add_string(5);
		else {
			if (get_char_status(get_selected_pc(), 28) >= 20) {
				add_string(7);
			}
			else {
				play_sound(24);
				add_string(1);
				change_coins(-3);
				// make drunk
				set_char_status(get_selected_pc(), 28, 2, 1, 0);
			}
		}
	break;

// *** June ***
begintalknode 20;
	state = -1;
	personality = 22;
	nextstate = 21;
	condition = 1;
	question = "June";
	text1 = "You see a (very) pretty blond woman wearing priest robes pacing around the temple.";
	text2 = "She smiles at the party asking _What can I help you with?_";
	text3 = "You know you've come to the right place to get your wounds healed.";
	text5 = "June acknowledges your presence.";
	text6 = "_You have come back to me_ she says.  _How can I help?_";
	text7 = "She patiently awaits your answer.";
	action = INTRO;

begintalknode 21;
	state = 21;
	personality = 22;
	nextstate = -1;
	condition = 1;
	question = "Do you date?";
	text1 = "June gives you a long stare.";
	text2 = "_Not with your kind._ she answers. _Maybe later when your sins have been washed off._";

begintalknode 22;
	state = 21;
	personality = 22;
	nextstate = -1;
	condition = (get_flag(0, 12) == 0);
	question = "What do you do?";
	text1 = "June answers _I provide healing to those in need for a small donation of 75 coins._";
	text2 = "_In addition, I can teach your priests some additional spells, for a price._";
	code =
		set_flag(0, 12, 1);
	break;

begintalknode 23;
	state = 21;
	personality = 22;
	nextstate = -1;
	condition = (get_flag(0, 12) > 0);
	question = "Can I learn some spells?";
	text1 = "You finish learning spells.";
	code =
		begin_shop_mode("June", "June can teach a vast number of spells to the deserving adventurer.  The prices are somewhat high.", 4, 4, -1);
	break;

begintalknode 24;
	state = 21;
	personality = 22;
	nextstate = -1;
	condition = (get_flag(0, 12) > 0);
	question = "I need some healing please (75 coins).";
	text1 = "June turns away saying _I am sorry, but I need a 75 coin donation before performing any healing._";
	text3 = "She smiles _That is good that you don't need any healing after all._";
	text5 = "June places her hand on your head.  You feel your energy and strength returning.  With a flash, you are completely healed.";
	code =
		clear_strings();
		if (coins_amount() < 75) 
			add_string(1);
		else if (run_select_a_pc(1) == 0)
			add_string(3);
		else {
			play_sound(24);
			add_string(5);
			restore_pc(get_selected_pc());
			change_coins(-75);
		}
	break;

// *** May ***
begintalknode 25;
	state = -1;
	personality = 23;
	nextstate = 26;
	condition = 1;
	question = "May";
	text1 = "You see a buxom blond woman reading a book behind the counter.";
	text2 = "She looks up asking _Hello, I'm May.  What can I do for you._";
	text3 = "Her pleasant smile is refreshing and brightens the room.";
	text5 = "May welcomes you back.";
	text6 = "_Can I show you a room?_ she asks.";
	action = INTRO;

begintalknode 26;
	state = 26;
	personality = 23;
	nextstate = -1;
	condition = 1;
	question = "What do you do?";
	text1 = "May giggles _Why, I run the Adverturer's Inn here in Llylgamyn._";
	text2 = "_Rooms run 100 coins per night._";
	text3 = "_Do you wish to rent a room?_ she asks.";

begintalknode 27;
	state = 26;
	personality = 23;
	nextstate = -1;
	condition = 1;
	question = "Do you want to join us for dinner?";
	text1 = "May smiles and replies _Maybe some later time.  I'm sort of busy right now._";

begintalknode 28;
	state = 26;
	personality = 23;
	nextstate = -1;
	condition = 1;
	question = "Can I get a room (100 coins)?";
	text1 = "May takes your money and shows you to a nice, clean room.";
	text2 = "You get some needed rest, awaking refreshed and ready to go.";
	text3 = "May giggles at what you are trying to pay.";
	text4 = "_Silly adverturers, rooms are 100 coins per night._";
	text5 = "May giggles at you _I don't rent rooms to horses sillies._";
	action = INN 100 20 31;

// *** August ***
begintalknode 30;
	state = -1;
	personality = 24;
	nextstate = 31;
	condition = 1;
	question = "August";
	text1 = "In the room is an experienced swordsman practicing with a sword.";
	text2 = "He is very skilled.";
	text3 = "He stops as you approach and extends his hand _Welcome, I'm August._";
	text4 = "_Are you in need of training?_";
	text5 = "August nods in your direction.";
	text6 = "_Do you wish training?_ he asks.";
	text7 = "_Don't forget to train._ he says.";
	action = INTRO;
	code =
		if (get_flag(0, 10) > 0) {
			remove_string(6);
		}
		else {
			remove_string(7);
		}
	break;

begintalknode 31;
	state = 31;
	personality = 24;
	nextstate = 31;
	condition = 1;
	question = "What do you do?";
	text1 = "August snorts _I train those in need of training here in Llylgamyn._";
	text2 = "He stares at you _Don't be wasting my time._";

begintalknode 32;
	state = 31;
	personality = 24;
	nextstate = 31;
	condition = (get_flag(0, 13) == 0);
	question = "How much to train?";
	text1 = "August replies _It will cost you 50 coins apiece to enter into the training room._";
	text2 = "_Is that agreeable?_";
	code =
		set_flag(0, 13, 1);
	break;

begintalknode 33;
	state = 31;
	personality = 24;
	nextstate = 31;
	condition = (get_flag(0, 13) > 0) && (get_flag(0, 10) == 0);
	question = "I'd like to train (50 coins apiece).";
	text1 = "August takes you money and unblocks the training room.";
	text2 = "_Here you go.  Train hard_ he says.";
	text3 = "_You don't have enough coins for your party_ August says.";
	text4 = "_Come back when you have the required amount._";
	code =
		tt = (party_size() * 50);
		clear_strings();
		if (coins_amount() < tt) {
			add_string(3);
			add_string(4);
		}
		else {
			play_sound(15);
			add_string(1);
			add_string(2);
			change_coins(0 - tt);
			set_flag(0, 10, 1);
		}
	break;

// *** Wanderer ***
begintalknode 35;
	state = -1;
	personality = 25;
	nextstate = 36;
	condition = 1;
	question = "Wanderer";
	text1 = "Ahead of you is an older man almost bent over with the heavy pack on his back.";
	text2 = "As you get closer, you hear the clanking of potion bottles rattling around.";
	text3 = "The man looks up at you as you approach _Hello, I'm a Wanderer._";
	text5 = "The Wanderer smiles as you approach.";
	text6 = "_Hello yet again.  Can I show you a few potions?_ he asks.";
	action = INTRO;

begintalknode 36;
	state = 36;
	personality = 25;
	nextstate = -1;
	condition = (get_flag(0, 14) == 0);
	question = "What do you do?";
	text1 = "He replies _I wander around selling potions to those in need._";
	text2 = "_Off and on, I may have other items that I've picked up for sale._";
	text3 = "_Can I interest you in a few potions, something else?_ he asks.";
	code =
		set_flag(0, 14, 1);
	break;

begintalknode 37;
	state = 36;
	personality = 25;
	nextstate = -1;
	condition = 1;
	question = "Why do you call yourself Wanderer?";
	text1 = "He replies _Because I wander around.  Sometimes here, sometimes there._";
	text2 = "He looks quizzenly at you _Why do you think I call myself Wanderer._";
	text3 = "He doesn't expect to get an intelligent answer from you.";

begintalknode 38;
	state = 36;
	personality = 25;
	nextstate = -1;
	condition = (get_flag(0, 14) > 0);
	question = "Can I see what you have for sale?";
	text1 = "You finish shopping with the Wanderer.";
	code =
		begin_shop_mode("Wanderer", "The Wanderer has potions and sometimes other items for sale.  The prices are somewhat high.", 3, 4, -1);
	break;

// *** Trebor ***
begintalknode 40;
	state = -1;
	personality = 17;
	nextstate = 41;
	condition = 1;
	question = "Trebor";
	text1 = "Up on the throne you see an imposing man wearing a crown.";
	text2 = "He checks out the party as you approach, eyes quickly darting back and forth.";
	text3 = "_I am Overlord Trebor_ he says.  _Are you here to go after *my* amulet?_";
	text4 = "You realize that deep down, the guy has had a break from reality.";
	text5 = "Trebor looks at the party with a mad (not angry) look on his face.";
	text6 = "_Will you get my amulet back?_";
	text7 = "_When will you get my amulet back?_";
	action = INTRO;
	code =
		if (get_flag(50, 0) == 0) {
			remove_string(7);
		}
		else {
			remove_string(6);
		}
		if (get_flag(50, 3) > 0) {
			remove_string(6);
			remove_string(7);
		}
	break;

begintalknode 41;
	state = 41;
	personality = 17;
	nextstate = -1;
	condition = 1;
	question = "What is the amulet?";
	text1 = "Trebor explains how he found a powerful amulet that will provide the wearer great power once it's secrets are unlocked.";
	text2 = "You lean back slightly as froth from Trebor's mouth sprays the party.";
	text3 = "He finishes his tale with the theft by Werdna and discovery of the maze under the city.";
	text4 = "_I have secured the first four levels, but haven't been able to get farther down_ Trebor says.";
	text5 = "_I need a band of adventurers willing to retrieve my amulet from Werdna and bring it back to me._";
	text6 = "_What amulet are you talking about?_ Trebor asks, eyes darting back and forth.";
	code =
		if (get_flag(50, 3) == 0) {
			remove_string(6);
		}
		else {
			clear_strings();
			add_string(6);
		}
	break;

begintalknode 42;
	state = 41;
	personality = 17;
	nextstate = -1;
	condition = (get_flag(50, 0) == 0);
	question = "We'll find your amulet.";
	text1 = "Trebor almost trembles with excitement _Thank you, I'll let the guards know you can enter the maze._";
	text2 = "With that, he sinks down into his throne, ignoring the party and muttering to himself.";
	action = END_TALK;
	code =
		set_flag(50, 0, 1);
		toggle_quest(0, 1);
	break;

begintalknode 43;
	state = 41;
	personality = 17;
	nextstate = -1;
	condition = (get_flag(50, 0) == 0);
	question = "I think we'll pass.";
	text1 = "Trebor flails his hand at you _Begone curs.  I knew you were too weak for the task anyhow._";
	text2 = "You almost laugh at the comical way he's ignoring you.";
	text3 = "You think better of it after seeing the expresion on the faces of the guards.";
	action = END_TALK;

begintalknode 44;
	state = 41;
	personality = 17;
	nextstate = -1;
	condition = (get_flag(50, 0) > 0) && (get_flag(50, 1) == 0);
	question = "We haven't found your amulet yet.";
	text1 = "Trebor eyes blaze and he screams _What are you doing here then, you imbeciles._";
	text2 = "He reaches down and pulls off a shoe which he hurls in your direction.";
	text3 = "_Don't come back until you have my amulet_ he screeches.";
	text4 = "Everyone in the room seems to be ignoring the outburst, but you move on before trouble starts.";
	action = END_TALK;

begintalknode 45;
	state = 41;
	personality = 17;
	nextstate = -1;
	condition = (get_flag(50, 3) > 0);
	question = "Hello again.";
	text1 = "Trebor looks suspiciously at the party _Who are you, what do you want?_";
	text2 = "_Leave me now!_ - It seems your chevrons aren't worth the thread that made them.";
	text3 = "After seeing the guards around you grabbing for their weapons, you take your leave.";
	action = END_TALK;

begintalknode 46;
	state = 41;
	personality = 17;
	nextstate = 47;
	condition = (get_flag(50, 0) > 0) && (get_flag(50, 1) > 0) && (get_flag(50, 3) == 0);
	question = "We have the amulet.";
	text1 = "Trebor leans forward expectantly _Let me have it_ he says with outstretched hand.";
	text2 = "_Let me have it, please_ he asks pleadingly.";
	text3 = "_Give it to me now or face the consequences_ he roars.";
	code =
		clear_strings();
		inc_flag(0, 15, 1);
		add_string(get_flag(0, 15));
	break;

begintalknode 47;
	state = 47;
	personality = 17;
	nextstate = -1;
	condition = has_item(452) == 0;
	question = "Sorry, don't have it on me.";
	text1 = "You believe that he is about to have a heart attack from the look on his face.";
	text2 = "_Go get it an bring it here._ he hisses, again spraying spit all over the party.";
	text3 = "He sinks back into his seat and glares at the party while waving them off.";
	text4 = "From the looks of the guards, you believe it'd be a wise move to move on.";
	action = END_TALK;

begintalknode 48;
	state = 47;
	personality = 17;
	nextstate = -1;
	condition = has_item(452) > 0;
	question = "OK, here it is.";
	text1 = "Trebor grabs the amulet from you, inspects it briefly, then makes it disappear.";
	text2 = "You realize that he has magically hid it so no one else will steal it from him.";
	text3 = "He claps his hands and says _Take these coins as my reward and these chevrons as my personal guard._";
	text4 = "With that he ignores the party.";
	action = END_TALK;
	code =
		set_flag(50, 3, 1);
		take_item(452);
		change_coins(1000);
		award_party_xp(750, 40);
		toggle_quest(0, 0);
	break;

begintalknode 49;
	state = 47;
	personality = 17;
	nextstate = -1;
	condition = 1;
	question = "No, I think I'll keep it.";
	text1 = "_Pretty please with cherries on top_ Trebor pleads some more.";
	text2 = "Trebor sits back, his eyes glinting coldly.";
	text3 = "Trebor whispers _So be it._  With a clap of his hand, he and the guards attack.";
	action = END_TALK;
	code =
		clear_strings();
		add_string(get_flag(0, 15));
		if (get_flag(0, 15) > 2) {
			make_town_hostile();
		}
	break;

// *** Am ***
begintalknode 55;
	state = -1;
	personality = 31;
	nextstate = 56;
	condition = 1;
	question = "Am";
	text1 = "Walking toward you is a colorful figure, covered in a shiny, billowing robe, muttering to himself.";
	text2 = "He doesn't seem to pay you much mind, but still seems to acknowlege your presence.";
	text3 = "_I am Am_ he states.";
	text5 = "Am stops muttering as you approach.";
	text6 = "_I am Am, do you need something?_ he asks.";
	action = INTRO;

begintalknode 56;
	state = 56;
	personality = 31;
	nextstate = -1;
	condition = (get_flag(0, 18) == 0);
	question = "What do you do?";
	text1 = "He replies _I am Am, mystic of afar._";
	text2 = "_I can teach you spells I've picked up, otherwise I've nothing for you._";
	text3 = "_Do you want nothing or spells?_ he asks.";
	code =
		set_flag(0, 18, 1);
	break;

begintalknode 57;
	state = 56;
	personality = 31;
	nextstate = -1;
	condition = 1;
	question = "Why are you called Am?";
	text1 = "He replies _I Am, you are not._";
	text2 = "_Are you not you?_ he asks.";
	text3 = "You're not quite sure he answered your question.";

begintalknode 58;
	state = 56;
	personality = 31;
	nextstate = -1;
	condition = (get_flag(0, 18) > 0);
	question = "I'd like to see your spells?";
	text1 = "You finish shopping with Am.";
	code =
		begin_shop_mode("Am", "Am has an array of magic spells the can be learned.  The prices are somewhat high.", 5, 4, -1);
	break;
